<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //你有一个 user 对象数组，每个对象都有 name，surname 和 id。
        //编写代码以该数组为基础，创建另一个具有 id 和 fullName 的对象数组，其中 fullName 由 name 和 surname 生成。：
        var users = [
            { name: "John", surname: "Smith", age: 25 },
            { name: "Pete", surname: "Hunt", age: 30 },
            { name: "Mary", surname: "Key", age: 28 }
        ];
        var usersMapped = users.map(function (elem) {
            return {
                fullName: elem.name + elem.surname,
            }
        });
        console.log(usersMapped[0].id); // 1
        console.log(usersMapped[0].fullName); // "John Smith"
    </script>
</body>

</html>